<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的银行卡</title>
    <link rel="stylesheet" type="text/css" href="../../../../css/aui/aui.css" />
    <style>
        html,
        body {
            background: #fff;
        }

        .list_wrap {
            padding: 1rem 0.75rem;
        }

        .list_item {
            display: flex;
            padding: 0.5rem;
            font-size: 1rem;
            border: 1px solid #eee;
            border-radius: 0.2rem;
            margin-bottom: 0.5rem;
        }

        .list_item img {
            width: 2.8rem;
            margin-right: 0.5rem;
        }

        .card_number {
            display: flex;
            align-items: center;
        }

        .card_number span {
            margin-right: 0.8rem;
            font-size: 1.2rem;
            line-height: 1.5rem;
            padding-top: 0.2rem;
        }

        .card_number span:nth-child(4) {
            font-size: 1rem;
            padding-top: 0;
            margin-right: 0;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="list_wrap">
            <div class="list_item" v-for="o,i in list" @click="unbund(o.bank_id,i)">
                <div><img :src="bankIcon[o.bank_code.toUpperCase()]" alt=""></div>
                <div>
                    <div>{{o.bank_name}}</div>
                    <div class="card_number">
                        <span>****</span><span>****</span><span>****</span><span>{{o.bank_card.substr(-4)}}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="../../../../script/api.js" charset="utf-8"></script>
<script src="../../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            userInfo: {},
            bankIcon: {
                'BOC': "../../../../image/icon/zhognguo_logo.png",
                'ICBC': "../../../../image/icon/gongshang_logo.png",
                'ABC': "../../../../image/icon/nongye_logo.png",
                'CBC': "../../../../image/icon/jianshe_logo.png",

                'CCB': "../../../../image/icon/jiaotong_logo.png",
                'PSBC': "../../../../image/icon/youzheng_logo.png",
                'CMB': "../../../../image/icon/zhaoshang_logo.png",
                'CIB': "../../../../image/icon/xingye_logo.png",

                'CMBC': "../../../../image/icon/mingsheng_logo.png",
                'CITIC': "../../../../image/icon/zhongxin_logo.png",
                'SPDB': "../../../../image/icon/pufa_logo.png",
            },

            list: [],
        },
        methods: {
            init() {
                this.userInfo = get_local("userInfo");
                this.getList();
            },
            getList() {
                var that = this;
                var data = {
                    user_id: this.userInfo.user_id,
                };
                _ajax(Config.api.UserBankGetLists, data, function(ret) {
                    if (ret.code === 200) {
                        that.list = ret.data;
                    }
                });
            },
            unbund(id, i) {
                var that = this;
                api.actionSheet({
                    cancelTitle: '取消',
                    buttons: ['解除绑定']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    if (index === 1) {
                        var data = {
                            user_id: that.userInfo.user_id,
                            bank_id: id
                        };
                        _ajax(Config.api.UserBankRemove, data, function(ret) {
                            if (ret.code === 200) {
                                that.list.splice(i, 1);
                                $toast('解除绑定');
                            }
                        });
                    } else {
                        $toast('取消');
                    }
                });
            },

        }
    });
</script>

</html>
